package com.JohnCarloSalter.Receipt;

import java.util.ArrayList;

public class Purchases {
	private ArrayList<PurchaseItem> purchases;
	
	public Purchases(ArrayList<PurchaseItem> p) {
		purchases = new ArrayList<PurchaseItem>(p);
	}
	
	public void print() {
		for(int i=0; i<purchases.size(); i++) {
			purchases.get(i).print();
		}
	}
	
	public String toString() {
		String returnString = "";
		for(int i=0; i<purchases.size(); i++) {
			returnString = returnString + purchases.get(i).toString() + "\n";
		}
		return returnString;
	}
	
	public double getTotal() {
		double total = 0;
		for(int i=0; i<purchases.size(); i++) {
			total += purchases.get(i).getPrice();
		}
		return total;
	}
	
	public ArrayList<PurchaseItem> getPurchases() {
		return purchases;
	}
	
	//This method is to "abstract out" the ArrayList requirements.
	public PurchaseItem getPurchase(int i) {
		return purchases.get(i);
	}
	
	//This method is to "abstract out" the ArrayList requirements.
	public int getNumberOfItems() {
		return purchases.size();
	}
}
